home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE4 / ZAP / !Zap / Code / Extensions / ExtAsm / ExtBasDoc < prev   
Text File  |  2002-05-08  |  22KB  |  673 lines

  1. Extended BASIC Assembler
  2. ————————————————————————
  3.  
  4. Version 2.01,         12 June 2000   (BASIC 1.05-1.16)
  5.         2.01 patch 2, 14 August 2000 (BASIC 1.20)
  6. by Darren Salt <ds@youmustbejoking.demon.co.uk>
  7. AOF code by Paul Clifford <paul@plasma.demon.co.uk>
  8. Contains code from v1.00 and v1.30 by Adrian Lees
  9.  
  10. (This is a beta version.)
  11.  
  12.  
  13. Licence
  14. ———————
  15.  
  16. ExtBASICasm is freeware. No restrictions are placed on its use; what you do
  17. with it is your own responsibility.
  18.  
  19. Release versions of ExtBASICasm may be freely distributed in unchanged form;
  20. patched versions may not be distributed unless the patches are *clearly*
  21. documented; such documentation must be distributed with the patched module.
  22.  
  23. Beta versions of ExtBASICasm must not be redistributed.
  24.  
  25.  
  26. Intro
  27. —————
  28.  
  29. It is recommended that you read through this document before first using this
  30. version of ExtBASICasm, and check through it quickly when upgrading. It's
  31. entirely possible that one of the extras the module provides may cause a
  32. clash with existing programs, for example the APCS-R register names clashing
  33. with variables used as register names.
  34.  
  35. Note also that APCS-R register names are disabled by default.
  36.  
  37.  
  38. The module ExtBASICasm provides a patch for various versions of BBC BASIC V
  39. to allow the direct use of the extra instructions provided by the ARM3, ARM6,
  40. ARM7 and StrongARM processors. The missing floating-point and general
  41. coprocessor instructions, and some assembler directives more familiar (and a
  42. few unfamiliar) to Acorn Assembler users have been added; also the APCS-R
  43. register names may be used. Also, AOF files may be generated.
  44.  
  45. To make the necessary changes to the BASIC module it must be located in RAM.
  46. The ExtBASICasm module will therefore attempt to RMFaster the BASIC module
  47. which will require a small amount of memory in the RMA, in addition to that
  48. required by the ExtBASICasm module itself. Attempting to run it while BASIC
  49. is active and in ROM will not work - try "*RMFaster BASIC" at the BASIC
  50. prompt and you'll see why.
  51.  
  52.   Ver    OS    Supported?
  53.   1.05    3.1x    Yes
  54.   1.06    3.5x    Yes
  55.   1.14    3.6x    Yes
  56.   1.16    3.7x    Yes
  57.   1.17    3.8x    Yes
  58.   1.18    4.00    No (1)
  59.   1.19    4.01    No (1)
  60.   1.20    4.0x    Yes
  61.  
  62. (1) Support for these versions will not be added since v1.20 is available for
  63.     softload on RISC OS 4.
  64.  
  65.  
  66. Enabling ExtBASICasm
  67. ————————————————————
  68.  
  69. Unlike some earlier versions, this version is initialised into a dormant
  70. state whenever you start up the BASIC interpreter, eg. by double-clicking on
  71. a BASIC program or by typing BASIC at the * prompt.
  72.  
  73. You can enable or disable the extensions by using the assembler pseudo-op
  74.     EXT n
  75. where n is 0 to disable and 1 to enable. (Other values are currently mapped
  76. to 1; do not rely on this.)
  77.  
  78. Setting any of the extension OPT bits *NO* *LONGER* enables ExtBASICasm.
  79.  
  80. Certain extensions remain enabled at all times: specifically, ALIGN always
  81. zero-fills, and the ".foo = bar" bug remains fixed. I don't think that
  82. this'll inconvenience anybody :-)
  83.  
  84.  
  85. ExtBASICasm uses the BASIC data word TIMEOF, which is documented as "unused"
  86. for all versions of BASIC V which it recognises, for its 'enabled' flag. It
  87. also uses the byte at &86E4 for its extended options byte.
  88.  
  89.  
  90. The instructions added by the module are as follows:
  91.  
  92.  
  93. Extensions
  94. ——————————
  95.  
  96.     Optional parts are enclosed in []
  97.  
  98. OPT    [<value>]
  99.     Bit 4:    ASSERT control (1 = enabled on 'second pass')
  100.     Bit 5:  APCS register names (1 = enabled)
  101.     Bit 6:    UMUL/UMULL control (0 = short forms, 1 = long forms)
  102.     Bit 7:    AOF control. If set, then the AOF extension is enabled.
  103.  
  104.     When ExtBASICasm is disabled, these bits take on their standard
  105.     meanings: bit 4 allows use of, amongst others, the FP instructions.
  106.  
  107.     If value is omitted, the previous setting is used.
  108.  
  109. EXT    <flag>
  110.     <flag>,<value>
  111.     <flag>,
  112.     Initialises or disables the extensions according to flag. The second
  113.     form allows you to simultaneously set the OPT value; the third (a
  114.     side effect of the use of the OPT code) causes the previous OPT value
  115.     to be used.
  116.  
  117. ALIGN
  118.     Zero-initialises the memory if required.
  119.  
  120. ALIGN    <const>[,<const2>]
  121.     Aligns to a multiple of const bytes plus an optional offset. const
  122.     must be a power of 2 between 1 and 65536; const2 must be between 0
  123.     and const-1 (default is 0). Also zero-initialises the memory.
  124.     P% becomes (P%+const-1 AND const-1)+const2; O% is also updated if
  125.     necessary. Examples:
  126.         ALIGN 4
  127.         ALIGN 32
  128.         ALIGN 16,8
  129.  
  130. MUL{cond}{S}    Rd,Rm,#<const>
  131.     variable length; Rd=Rm if <2 ADD/RSB
  132.     May cause 'duplicate register' if Rd=Rm and const is not simple - ie.
  133.     not 0, (2^x)-1, 2^x, (2^x)+(2^y)
  134.  
  135. MLA{cond}{S}    Rd,Rm,#<const>,Ra
  136.     variable length; Rd=Rm if <2 ADD/RSB
  137.     Rd=Ra causes 'duplicate register' error if const is not simple, as
  138.     for MUL; Rd=Rm=Ra is special in that MLA Rd,Rd,#c,Rd = MUL Rd,Rd,#c+1
  139.     If Rd=Ra and const=0, no code is generated (none necessary).
  140.  
  141. DIV        Rq,Rr,Rn,Rd,Rt [SGN Rs]
  142.     Integer division by register
  143.     Rq = quotient        Rn = numerator        Rt = temporary store
  144.     Rr = remainder        Rd = denominator    Rs = sign store
  145.     If Rs omitted then division is unsigned.
  146.     Rr may be same register as Rn *or* Rn may be same as Rs.
  147.     All other registers must be different.
  148.     Rt and Rs (if specified) are corrupted.
  149.  
  150. DIV        Rq,Rr,Rn,#d[,[Rt]] [SGN Rs]
  151.     Integer division by constant
  152.     Registers as above
  153.     If Rs omitted then division is unsigned.
  154.     If Rt omitted and is required for this division then error given.
  155.     All registers must be different.
  156.     If specified, Rt and Rs are corrupted.
  157.     (Uses generator to build code - fast but may be long)
  158.     Notes:    Uses Fourier method. For unsigned values, this is fixed to
  159.         handle unsigned top-bit-set properly, *except* for div by 3
  160.         which works for values up to &C0000000. Ideas and code
  161.         gratefully received...
  162.  
  163.     *** Note no conditional for DIV
  164.  
  165. SQR        Rt,Rr,Rx,Ry
  166. SQR        Rt,Rr,{Rx,Ry}
  167.     Square root
  168.     Input    Rr = value, Rx & Ry = work registers
  169.     Output    Rt = square root, Rr = remainder, Rx = 0, Ry corrupt
  170.         In effect, Rt = INT SQR Rr and Rr' = Rr-Rt*Rt
  171.     If {} are used, then Rx and Ry are preserved via STMFD R13!,{Rx,Ry}
  172.     and restored via LDMFD R13!,{Rx,Ry}.
  173.  
  174.     *** Note no conditional for SQR
  175.  
  176. ADR{cond}L    Rd,<const>
  177.     Fixed length (two words)
  178.  
  179. ADR{cond}X    Rd,<const>
  180.     Fixed length (three words)
  181.  
  182. ADR{cond}W    Rd,<const>
  183.     Addressing relative to R12, one to three words
  184.     <const> MUST be defined before it is used
  185.     Adds/subtracts const to/from R12, storing result in Rd
  186.     Up to you to ensure that R12 correctly set up...
  187.  
  188. LDR, STR
  189.     xxx{cond}{B}W    Rd,<offset>
  190.       Load/store word/byte at [R12,#<offset>]
  191.  
  192.     LDR{cond}{B}L    Rd,<address>
  193.     LDR{cond}{B}L    Rd,[Rm,#<offset>]{!}
  194.     LDR{cond}{B}WL    Rd,<offset>
  195.     STR equivalents
  196.       Addressing range is ±1MB; some offsets outside this range are also
  197.       valid. Lengths are (in words):
  198.         LDR           2  ADD/SUB Rd,Rm,#a:LDR Rd,[Rd,#b]
  199.         LDR ...]!  2  ADD/SUB Rm,Rm,#a:LDR Rd,[Rm,#b]!
  200.         STR           3  ADD/SUB Rm,Rm,#a:STR Rd,[Rm,#b]:SUB/ADD Rm,Rm,#a
  201.         STR ...]!  2  ADD/SUB Rm,Rm,#a:STR Rd,[Rm,#b]!
  202.  
  203.     LDR{cond}{B}L    Rd,{Rn},<address>
  204.     LDR{cond}{B}L    Rd,{Rn},[Rm,#<offset>]
  205.     LDR{cond}{B}WL    Rd,{Rn},<offset>
  206.     STR equivalents
  207.       [{Rn} is NOT optional]
  208.       Equivalent to the LDR/STRs above, except that Rn (rather than Rd)
  209.       is used to hold the address; always two words long. For example,
  210.       ADRL R0,wibble:LDR R1,[R0] may be replaced with LDRL R1,{R0},wibble
  211.       - one word shorter.
  212.       Rd=Rn is not allowed.
  213.       Assembles to ADD/SUB Rn,Rm,#a : LDR/STR Rd,[Rn,#b]!
  214.  
  215.     LDR{cond}{B}L    Rd,[Rm],#<offset>
  216.     STR equivalent
  217.       Addressing range is ±1MB; some offsets outside this range are also
  218.       valid. Two words long.
  219.       Assembles to LDR/STR Rd,[Rm],#b:ADD/SUB Rm,Rm,#a
  220.  
  221.     NOTE: You should try to avoid using *sequences* of LDRLs or STRLs -
  222.     there is usually a more efficient way.
  223.  
  224.     LDRxxH, LDRxxSH, LDRxxSB and STRxxH
  225.         The W forms are supported.
  226.         Long LDR{H|SH|SB} not yet implemented.
  227.  
  228. SWAP{cond}[S]    Rd,Rn
  229.     Swaps Rd and Rn without using temporary store.
  230.     Uses EOR method, is therefore three words long.
  231.     If S is specified, then the flags are set according to Rn.
  232.  
  233. VDU{cond}{X}    <const>
  234.     = SWI "OS_WriteI"+<const>
  235.     With X present, XOS_WriteI is used instead.
  236.  
  237. NOP{cond}
  238.     = MOV{cond} R0,R0
  239.     (BASIC supports only an unconditional NOP.)
  240.  
  241. BRK{cond} [#<const>]
  242.     Undefined instruction. If <const> is specified, then R14 is set to
  243.     this value before the undefined instruction trap is taken.
  244.  
  245. EQUx, DCx, =
  246.     xxx <value>[,<value>]^
  247.     Extended form of EQUD, EQUW, DCB, etc.
  248.     Instead of, eg. DCD 0 : DCD 12 : DCD branch
  249.     you can now use DCD 0, 12, branch
  250.  
  251. Negative constants
  252.     Allowed in the following instructions:
  253.         ADD, SUB    ADC, SBC    ADF, SUF
  254.         AND, BIC    MOV, MVN    MVF, MNF
  255.         CMP, CMN    CMF, CNF    CMFE, CNFE
  256.     If the constant is invalid for one of these, it is negated or
  257.     inverted, as appropriate, and the instruction changed to the other of
  258.     the pair (eg. ADC becomes SBC). If the constant is still invalid, the
  259.     "bad immediate constant" error is generated as normal.
  260.  
  261.  
  262. ARMv3 (ARM6) and later
  263. ——————————————————————
  264.  
  265. MSR{cond}    <psr>_<f>,Rm
  266.     (Standard extension.)
  267.     <f> may, in addition to the standard combinations of 'c' 'x' 's' 'f',
  268.     be one of:
  269.         ctl    control bits only
  270.         flg    flag bits only
  271.         all    both
  272.     Any combination of 'cf' is equivalent to 'all'; you may also, in the
  273.     standard form, use '_' between letters.
  274.  
  275.  
  276. ARMv4 (ARM8, StrongARM) and later
  277. —————————————————————————————————
  278.  
  279. UMUL, SMUL, UMLA, SMLA:
  280.     xxx{cond}{S}    Rl,Rh,Rm,Rn
  281.  
  282.     The 'official' forms UMULL, SMULL, UMLAL, SMLAL are used *instead of*
  283.     the 'short' forms if extended OPT bit 6 is set.
  284.     Unfortunately it's not possible to allow both forms at once: how
  285.     would you interpret "UMULLS" - UMUL condition LS or UMULL with S bit?
  286.  
  287.  
  288. Floating-point instructions
  289. ———————————————————————————
  290.  
  291. Floating point coprocessor data transfer
  292.  
  293. LDF, STF:
  294.     xxx{cond}precW    Fd,<offset>
  295.  
  296. LFM{cond}{stack}    Fd,m,[Rn]{!}
  297. SFM{cond}{stack}    Fd,m,[Rn]{!}
  298. LFS{cond}{stack}    Rn{!},<fp register list>
  299. LFS{cond}{stack}    Rn{!},<fp register list>
  300.  
  301.     LFM, SFM, LFS and SFS use extended precision. The <fp register list>
  302.     is much as for LDM and STM, with restrictions: you must specify a
  303.     register or a sequence of registers, and the list must be compatible
  304.     with LFM and SFM - eg.
  305.     LFSFD R13!,{F3}        LFMFD F3,1,[R13]!    LFM F3,1,[R13],#12
  306.     SFSFD R13!,{F5-F0}    SFMFD F5,4,[R13]!    SFM F5,4,[R13,#-36]!
  307.     LFSDB R13,{F1,F0}    LFMDB F0,2,[R13]    LFM F0,2,[R13,#-24]
  308.     - for each row, all the instructions have the same effect.
  309.     Available stack types are DB, IA, EA, FD.
  310.     Note that example 2 wraps around - F5, F6, F7, F0 _in that order_.
  311.  
  312.  
  313. Assembler directives
  314. ————————————————————
  315.  
  316. * Conditional - will STOP if expression is FALSE:
  317.  
  318. ASSERT    <expression>
  319.  
  320.     Bit 4 of the extended OPT value controls ASSERT. When it and bit 1
  321.     are zero, ASSERTs are ignored.
  322.  
  323. * Constants
  324.  
  325. =    <const|string>
  326.     The bug causing an error when used in the form
  327.         .label = "something"
  328.     has been fixed.
  329.  
  330. EQUF, DCF
  331.     xxx    <const>
  332.  
  333.     Synonyms for EQUFD.
  334.  
  335. EQUP, DCP, P
  336.     xxx    <string>,<const>
  337.     xxx    <const>,<string>
  338.     Fixed-length string allocation. If the string is too short, then the
  339.     remaining space is padded with nulls; if it is too long, it is
  340.     truncated to the specified length.
  341.  
  342. EQUPW, DCPW, PW
  343.     xxx    <pad_byte>,<string>,<const>
  344.     xxx    <pad_byte>,<const>,<string>
  345.     Like EQUP, except that you specify the padding byte.
  346.  
  347. EQUZ, DCZ, Z
  348.     xxx    <string>
  349.     EQUS with automatic zero termination
  350.  
  351. EQUZA, DCZA, ZA
  352.     xxx    <string>
  353.     Equivalent to EQUZ followed by ALIGN
  354.  
  355.     Note: *ALL* the EQU... directives (and their equivalents) may have
  356.     their arguments repeated as described in the Extensions section.
  357.  
  358. FILL, %
  359.     xxx{B|W|D}    <const>{,{<value>}}
  360.     Allocates <const> bytes of memory, initialised to <value> (or 0).
  361.     B, W and D represent data lengths as for EQU; if omitted, then byte
  362.     length is assumed. If the comma is present but no fill value, this is
  363.     equivalent to adding the constant to P% (and O% if appropriate).
  364.  
  365. FILE    <filename>
  366.     Loads the specified file, allocating just enough space for it.
  367.  
  368. ^    <offset>
  369.     Initialises the workspace address pointer to the given value.
  370.     This is used and updated by #.
  371.     Typical use:
  372.         ^ 0
  373.         ...
  374.         # flags, 4
  375.         ...
  376.         LDRW    R0,flags
  377.  
  378. #    <variable>, <length>
  379.     Sets the variable to the current value of the workspace address
  380.     pointer, which is then incremented by <length>.
  381.     This does not alter P% or O%.
  382.     (Note: the variable is assigned before the length is evaluated.)
  383.  
  384. COND    <cond>
  385.     Sets the condition code for use with = (when used as a condition
  386.     code). It may be supplied as a condition code literal, a number (0 to
  387.     15), or a string containing a condition code literal. For example,
  388.     all of the following are equivalent:
  389.         COND    7        ; number
  390.         COND    VC        ; condition code literal
  391.         COND    vc        ; condition code literal
  392.         COND    "Vc"        ; string containing cond. code lit.
  393.     Example code:
  394.         COND    LT        ; select LT condition code
  395.         MOV=    R0,#2        ; MOVLT  R0,#2
  396.         MOV=S    R1,R2        ; MOVLTS R1,R2
  397.  
  398.  
  399. AOF generation
  400. ——————————————
  401.  
  402. AREA    "name", "attributes"
  403.  
  404.     An area is a named block of code or data that can be manipulated by a
  405.     linker, such as drlink, to form the final program image. Typically, a
  406.     program will be divided into two main areas; one for code and the
  407.     other for data. For example, Acorn's C compiler uses areas named
  408.     "C$$code" and "C$$data".
  409.  
  410.     Each area has a set of attributes which provide extra information to
  411.     the linker. The attributes recognised by ExtBASICasm are listed below
  412.     (the case is ignored):
  413.  
  414.     32BIT        The code complies to the 32-bit variant of the APCS.
  415.     CODE        Contains machine code instructions.
  416.     DATA        Contains data, not instructions.
  417.     EXTFP        The extended floating-point instruction set is used (LFM
  418.             and SFM instead of multiple LDFEs and STFEs).
  419.     NOCHECK        The code complies with a variant of the APCS without
  420.             software stack-limit checking.
  421.     PIC        Position Independent Code; will execute where loaded
  422.             without modification.
  423.     READONLY    This area will not be written to.
  424.     REENTRANT   The code complies with the reentrant APCS standard.
  425.  
  426.     Each attribute should be separated from the next by a comma (spaces
  427.     are optional and ignored when processing the list). It is important
  428.     to make sure that all areas of the same name also have the same
  429.     attributes, otherwise the linking process will fail.
  430.  
  431.     Example area definitions:
  432.  
  433.     AREA    "C$$code", "CODE, READONLY"
  434.     AREA    "MyProgram$Data", "DATA"
  435.  
  436.  
  437. IMPORT    "symbol" ["attributes"]
  438. IMPORT    "symbol", "alternative name" ["attributes"]
  439.  
  440.     References between areas are handled via "symbols". Each area exports
  441.     a list of symbols that are available for external use, eg "strlen",
  442.     "printf", and "fread" from the C library stubs. An area can then
  443.     import the symbol and use it as if it were defined locally, leaving
  444.     the linker to resolve the references later.
  445.  
  446.     IMPORT makes an external symbol available for use within the current
  447.     area. It creates a variable of the same name, ending with an @, which
  448.     can be used with STR, LDR, EQUD, EQUW and B instructions. An
  449.     alternative name can be supplied, making it possible to import
  450.     symbols containing characters that are illegal in a BASIC variable
  451.     name, such as $. Example uses:
  452.  
  453.     IMPORT  "strcpy"        ; import strcpy as strcpy@
  454.     IMPORT  "an$example", "example" ; import an$example as example@
  455.  
  456.     BL    strcpy@            ; call the strcpy routine
  457.     LDR    R0, example@        ; load a word from an$example
  458.  
  459.     Note: The '@' variables should always be treated as read-only.
  460.  
  461.     The optional attributes are as follows:
  462.  
  463.     FPREG        This is only meaningful if the imported symbol is a
  464.             function entry point and indicates that floating point
  465.             arguments will be passed in floating point registers.
  466.     INSENSITIVE The linker will ignore the case when trying to resolve
  467.             the reference.
  468.     NOCASE        A synonym for INSENSITIVE.
  469.     WEAK        It is acceptable for the reference to remain unsatisfied.
  470.  
  471.     Example:
  472.  
  473.     IMPORT  "xyz", "abc" ["nocase"] ; import xyz as abc@, ignoring case
  474.  
  475.  
  476. EXPORT    "symbol" ["attributes"]
  477. EXPORT    "symbol", "alternative name" ["attributes"]
  478.  
  479.     EXPORT makes an address within the current area available for outside
  480.     use. The "symbol" is the BASIC variable containing the address and,
  481.     if the alternative name is missing, the name under which it is
  482.     exported. If the variable is an integer you would probably want to
  483.     supply an alternative name to remove the % at the end. Example uses:
  484.  
  485.     EXPORT  "compare%", "uint_cmp"  ; export compare% as uint_cmp
  486.     EXPORT  "value", "an$integer"    ; export value as an$integer
  487.     EXPORT  "value"            ; also export value as value
  488.  
  489.     .compare%
  490.     CMP    R0, R1
  491.     MOVLO    R0, #-1
  492.     MOVEQ    R0, #0
  493.     MOVHI    R0, #1
  494.     MOVS    PC, R14
  495.     .value
  496.     DCD    &12345678
  497.  
  498.     The optional attributes are:
  499.  
  500.     DATA    This is only meaningful if the symbol occurs in a code area,
  501.         and indicates that the symbol defines data rather than code.
  502.     FPREG    This is only meaningful if the symbol defines a function
  503.         entry point and indicates that floating point arguments
  504.         should be passed in floating point registers.
  505.     LEAF    The symbol defines a function call that makes no calls to any
  506.         any other functions.
  507.     STRONG    This symbol should be used in preference to any other
  508.         non-strong symbol when resolving references in other files.
  509.         Any references to the symbol within the same file as the
  510.         strong definition resolve to the non-strong definition. This
  511.         allows a kind of link-time indirection.
  512.  
  513.     Example:
  514.  
  515.     EXPORT  "leaf_fn" ["leaf"]    ; export leaf_fn as a leaf symbol
  516.  
  517.  
  518. INCLUDE    "filename"
  519.  
  520.     INCLUDE will load the specified BASIC program as a library (first
  521.     pass only) and call the definition of FNinclude in that program, if
  522.     one exists. The function call ignores definitions of FNinclude
  523.     elsewhere, such as other INCLUDE'd files.
  524.  
  525.  
  526. END
  527. SAVE    "filename"
  528.  
  529.     It is necessary to explicitly mark the end of an AOF file, to allow
  530.     the extra data to be inserted in the correct place, and to provide a
  531.     means of determining how many passes have been carried out. Either
  532.     END or SAVE "filename" can be used for this purpose; the latter will
  533.     automatically save the AOF output on the second pass. For example:
  534.  
  535.     SAVE    "o.program"
  536.  
  537.  
  538. LDR    register, =expression
  539. LDF*    register, =expression
  540. LTORG
  541.  
  542.     Literals are used to load immediate values that cannot be handled by
  543.     the MOV/MVN and MVF/MNF instructions. The expression is evaluated and
  544.     stored in the nearest following literal pool, and the instruction is
  545.     assembled to load from the value from this address. If the expression
  546.     contains an imported symbol, the necessary relocation directive will
  547.     be transparently added.
  548.  
  549.     A literal pool is automatically added at the end of each area, but
  550.     extra literal pools can be created using the LTORG directive. This is
  551.     particularly useful when using floating point literals as the LDF
  552.     instruction only has a range of +-1020.
  553.  
  554.     Examples:
  555.  
  556.     LDR    R0, =&4b534154        ; R0 = &4b534154 ("TASK")
  557.     LDFS    F1, =3.1415926536    ; F1 = (float) 3.1415926536
  558.     LDR    R7, =external@ + 4    ; R7 = address of external + 4
  559.  
  560.  
  561. HEAD    "function name"
  562.  
  563.     This adds a function name header, used by backtraces and
  564.     disassemblers to name functions. For example:
  565.  
  566.     EXPORT  "compare"
  567.     HEAD    "compare"
  568.     .compare
  569.     ; ...
  570.     MOVS    PC, R14
  571.  
  572.  
  573. ENTRY
  574.  
  575.     The ENTRY directive is used to tell the linker where program
  576.     execution should begin.
  577.  
  578.  
  579. ORG    address
  580.  
  581.     ORG sets a base address for the current area. It should be used
  582.     carefully as it may cause problems for the linker, and only really
  583.     makes sense if the code needs to be mapped to a fixed hardware
  584.     location.
  585.  
  586.  
  587. ROUT
  588. ROUT    "routine name"
  589.  
  590.     ROUT marks the beginning of a new local label block. Local labels can
  591.     be defined multiple times in a single source file and are
  592.     particularly useful in macros. For example:
  593.  
  594.     DEF FNexample
  595.     [    OPT    pass%
  596.         ROUT
  597.         TST    R0, #1
  598.         BNE    @10
  599.         ; ...
  600.         B    @20
  601.     .10
  602.         ; ...
  603.     .20
  604.     ]
  605.     = 0
  606.  
  607.     A local label always starts with a number and can optionally be
  608.     followed by the routine name, as supplied to the preceding ROUT. It
  609.     is an error to supply differing names; local labels outside the
  610.     current label block are hidden. References to a local label begin
  611.     with an @.
  612.  
  613.  
  614. Notes
  615. —————
  616.  
  617. * Registers are specified in the following form:
  618.  
  619.     ARM registers:            R0..R15
  620.         using APCS-R names:    A1..A4 V1..V6 SL FP IP SP LR PC
  621.     Floating-point registers:    F0..F7
  622.     General co-processor registers:    C0..C15
  623.  
  624.   To help to cope with any potential name clashes, the floating point and
  625.   APCS-R register names (except for PC) must be terminated with some
  626.   character not valid in a variable name in order to be recognised; they are
  627.   otherwise treated as part of a variable name.
  628.  
  629. * Coprocessor numbers (CP#) may be specified using either of the following
  630.   forms:
  631.  
  632.     P0..P15
  633.     CP0..CP15
  634.  
  635. * Wherever a register or coprocessor number is specified, an expression may
  636.   be substituted in the usual manner allowed by BASIC V. This module employs
  637.   the routines used within BASIC to evaluate all expressions (eg. register
  638.   numbers, offsets and labels) and hence its interpretation of expressions is
  639.   guaranteed to be the same as BASIC.
  640.  
  641.  
  642. Credits
  643. ———————
  644.  
  645.   Adrian Lees (last known, AFAIK, at A.M.Lees-CSEE93@@cs.bham.ac.uk):
  646.   - for the original ExtBas and the EQU comma extension, and for the use of
  647.     some of his code
  648.  
  649.   Michael Rozdoba (mroz@argonet.co.uk; remember TechForum?):
  650.   - for including the "General recursive method for Rb := Ra * C, C a
  651.     constant" from Appendix C of the manual for Acorn's desktop assembler,
  652.     and the late Acorn Computing (Sept 1994) for printing it;
  653.   - for the division code generator (Archimedes World, May 1995), which was
  654.     included, slightly trimmed, and debugged to handle top-bit-set unsigned
  655.     numbers properly... I hope!
  656.  
  657.   Dominic Symes of !Zap fame (dominic.symes@armltd.co.uk):
  658.   - for pointing out that ANDEQ R0,R0,R0 could usefully be replaced by DCD 0
  659.  
  660.   Martin Willers (m.willers@tu-bs.de):
  661.   - for bug hunting :-)
  662.  
  663.   Reuben Thomas (rrt1001@cam.ac.uk):
  664.   - for pointing out it might be useful to disable the APCS register names,
  665.     suggesting B/W/D suffix for FILL (and %) and -ve immediate constants, and
  666.     bug encountering
  667.  
  668.   Mohsen Alshayef (mohsen@qatar.net.qa):
  669.   - for some useful long MUL, STRH and [CS]PSR info
  670.  
  671.   Michael Kircher (kircher@ph-cip.uni-koeln.de):
  672.   - for the integer square root code, and a few bug reports
  673.